<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/28
 * Time: 17:55
 */

namespace app\api\controller\v1;
use app\api\model\Theme as ThemeModel;
use app\api\validate\IDCollection;
use app\api\validate\IDMustBePositiveInt;
use app\lib\Exception\ThemeMissException;

class Theme
{
    public function getThemes($ids=''){
        (new IDCollection())->toCheck();
        $idArray = explode(',',$ids);
        $theme = ThemeModel::getThemesByIDs($idArray);
        if($theme->isEmpty()){
            throw new ThemeMissException();
        }
        return $theme;
    }

    public function getBooksWithTheme($id){
        (new IDMustBePositiveInt())->toCheck();
        $result = ThemeModel::getBooks($id);
        if(!$result){
            throw new ThemeMissException();
        }
        return $result;
    }
}